package com.gitee.proxy.handler;

import com.gitee.proxy.server.ServerConfig;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.handler.codec.http.HttpServerCodec;

public class ServerInitalizer extends ChannelInitializer {

    private ServerConfig serverConfig;

    public ServerInitalizer(ServerConfig serverConfig) {
        this.serverConfig = serverConfig;
    }

    @Override
    protected void initChannel(Channel ch) throws Exception {
        ch.pipeline().addLast("httpServerCodec", new HttpServerCodec());
        ch.pipeline().addLast("serverHandler", new ServerHandler(serverConfig));
    }
}
